/*
...rest  操作符：相当于合并
// 解构赋值，合并【合并剩余项】

...扩展运算符    :展开，


const color = "yellow"
const unameKey = "uname"
const person = {
	// uname: "张三",
	[unameKey]: "张三",
	["a" + "bc"]: "abc",
	age: 23,
	// sayHi: function() {
	sayHi() {
		console.log("hi")
	},
	// color: "yellow"
	// color: color
	color,
}
// person.sayHi()
console.log(person)

// const { uname, ...other } = person
// console.log(other)

console.log({
	...person,
	active() {
		console.log("runing")
	}
})

*/


const target = {
	a: 1,
	// b: "b",
	// c: "c"
}
const s1 = {
	b: "b",
	c: "ccc"
}
const s2 = {
	c: "c",
	a: "a",
}
// 合并对象
// const res = Object.assign(target, s1, s2)
// const res = Object.assign(target, s2, s1)
const res = {
	...target,
	...s2,
	...s1,
}
// console.log(res)
// console.log(target)
// console.log(res === target) // true

// 浅拷贝
// const res1 = Object.assign({}, target)
// res1.a = "aaaaaa"
// console.log(res1)
// console.log(target)

const res1 = {...res}
res1.a = "aaaaaa"
// console.log(res1)
// console.log(res)

// [].keys()
Object.keys(res1).forEach(item => {
	console.log(item)
})
Object.values(res1).forEach(item => {
	console.log(item)
})
Object.entries(res1).forEach(item => {
	console.log(item)
})
console.log(Object.entries(res1))
console.log(Object.fromEntries(Object.entries(res1)))


const search = "?cl=3&tn=baidutop10&fr=top1000&wd=勇于自我革命赢得历史主动&rsv_idx=2&rsv_dl=fyb_n_homepage&sa=fyb_n_homepage&hisfilter=1"
const searchArr = search.slice(1).split("&")
const erwei = searchArr.map(item => {
	return item.split("=")
})
console.log(searchArr)
console.log(erwei)
console.log(Object.fromEntries(erwei).fr)
console.log(Object.fromEntries(erwei).wd)



